<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录界面</title>
</head>
<link rel="stylesheet" href="css/modules/code.css">
<link rel="stylesheet" href="css/modules/laydate/default/laydate.css">
<link rel="stylesheet" href="css/modules/layer/default/layer.css">
<link rel="stylesheet" href="css/layui.css">
<link rel="stylesheet" href="css/login.css">


<style>

#backLoginDemo{
    width: 200px;
    height: 38px;
    margin-left: 255px;
    margin-top: 20px;
}

</style>

<body>
    <div id="loginFrame">
        <p>
            梦 创 软 件 科 技
        </p>
        <form id="loginForm">
            <div>
                <input type="text" id="account" name="account" required lay-verify="required" placeholder="请输入账号"
                    autocomplete="off" class="layui-input">
            </div>
            <div>
                <input type="PassWord" id="pwd" name="pwd" required lay-verify="required" placeholder="请输入密码"
                    autocomplete="off" class="layui-input">
            </div>

            <button type="button" id="loginDemo" class="layui-btn layui-btn-fluid" onclick="htefer()">登录</button>
            <button type="button" id="regisTered" class="layui-btn layui-btn-fluid" onclick="restereds()">注册</button>
            <button type="button" id="backLoginDemo" class="layui-btn layui-btn-fluid" onclick="backHtefer()">站主登录</button>

    </div>
    </form>
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
    //登录
    function htefer() {
        let usersText = $('#account').val();
        let pwdText = $('#pwd').val();
        if (usersText.length > 0 && pwdText.length > 0) {
            $.ajax({
                url: "/loginDone",
                type: "POST",
                data: $('#loginForm').serialize(),
                dataType: "json",
                success: function (res) {
                    console.log(res);
                    if (res.code === 200) {
                        window.location.href = "/index";
                    } else {
                        alert('请输入正确的账号或密码')
                    }
                }
            })
        } else {
            alert('NOT FROM 404')
        }
    };
    //注册
    function restereds() {
        window.location.href = '/registered'
    }

    function backHtefer(){
        window.location.href = '/backlogin'
    }
</script>

</html>